package com.itlong.cloud.iot.alibaba.util;

import com.aliyun.mns.client.CloudAccount;
import com.itlong.cloud.PlatformConstants;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

/**
 * <desc>
 *      阿里云通信环境初始化
 * </desc>
 *
 * @createDate 2018/04/10
 */
@Component
@RefreshScope
public class AliClient {
    @Value("${" + PlatformConstants.IOT_ACCESS_KEY_ID + "}")
    private  String iotAccessKeyId;  //阿里云颁发给用户的访问服务所用的密钥ID
    @Value("${" + PlatformConstants.IOT_ACCESS_KEY_SECRET + "}")
    private  String iotAccessKeySecret; //阿里云访问服务器秘钥

    /**
     * <desc>
     *      获取阿里云通信对象
     * </desc>
     *
     * @param endpoint 通信服务器地址
     * @return
     * @author Jiaqi.X
     * @createDate 2018/03/17
     */
    public  CloudAccount getCloudAccount(String endpoint){
        return new CloudAccount(iotAccessKeyId,iotAccessKeySecret,endpoint);
    }

}
